<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/1/1
 * Time: 18:11
 */

//nl2br — 在字符串所有新行之前插入 HTML 换行标记
//string nl2br ( string $string [, bool $is_xhtml = true ] )
echo nl2br("this is a text \nhappy new year");
echo PHP_EOL;
echo nl2br("\nthis is the first of the year");
echo PHP_EOL;
echo nl2br("\nthis is the first of the year",false);

echo PHP_EOL;


//todo ???????
$string = "This\r\nis\n\ra\nstrings\n";
$string2 = "This\r\nis\n\ra\nstrings\r";
echo nl2br($string);
echo nl2br($string2);